package com.haoran.springboot;

import com.haoran.springboot.model.Person;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@Controller
public class SpringbootApplication {
    @RequestMapping("/")
    public String index(Model model){
        Person single = new Person("aa",11);
        List<Person> peole=new ArrayList<>();
        Person p1 = new Person("xx",11);
        Person p2 = new Person("yy",22);
        Person p3 = new Person("zz",33);
        peole.add(p1);
        peole.add(p2);
        peole.add(p3);
        model.addAttribute("singlePerson",single);
        model.addAttribute("people",peole);

        return "index";
    }
    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }

}
